<template>
  <div>
    <el-button @click="dialogVisible = true" type="primary" class="btnRight">编辑</el-button>
    <h3 class="title">平台简介</h3>
    <div class="content" v-html='formData.content'></div>
    <!--弹框-->
    <el-dialog
  title="提示"
  :visible.sync="dialogVisible"
  width="50%"
  :before-close="handleClose">
   <editor :editorContent="formData"></editor>
  <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="submitBtn">确 定</el-button>
  </span>
</el-dialog>


  </div>
</template>

<script type="text/ecmascript-6">
import { reqIntroduce, reqIntroduceEdit } from "../../api";
import { formDate } from "../../utils/Date.js";
export default {
  data() {
    return {
      dialogVisible: false,
      formData:{
        content:'哈哈哈，我是小耍',
        id:'1'
      },
      user:JSON.parse(localStorage.getItem('token_data')),
    };
  },
  created(){
    reqIntroduce().then(res=>{
      this.formData.content = res[0].content;
      this.formData.id = res[0]._id;
    }).catch(err=>{console.log(err)})
  },
  mounted() {
  },
  methods: {
     handleClose(done) {
        this.$confirm('确认关闭？')
          .then(_ => {
            done();
          })
          .catch(_ => {});
      },
    submitBtn(){
      this.$eventBus.$emit("submit");
      reqIntroduceEdit(this.formData).then(res=>{
        this.dialogVisible = false;
        this.$message({
          message: '修改成功',
          type: 'success'
        });
      }).catch(err=>{
        console.log(err),
      this.$message({
          message: '修改失败',
          type: 'error'
        });
    })
    }
  },
  components: {
     editor:() => import("@/components/editor")
  }
};
</script>

<style scoped >
.title{
  font-size: 25px;
  text-align: center;
  padding-top:15px;
}
.content{
  text-indent: 2em;
}
.btnRight {
  float: right;
  margin:10px 15px 0 0;
  
}

</style>
